Skip to content

A port of Blender's AgX to darktable #19026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

kofa73
Copy link
Contributor

@kofa73 kofa73 commented Jun 29, 2025

An attempt to port Blender's AgX tone mapper to darktable, based on @EaryChow's https://github.com/EaryChow/AgX_LUT_Gen/blob/main/AgXBaseRec2020.py.

  • The curve, look and primaries parameters are exposed as sliders, with some pickers to help users.
  • Early user feedback is being collected at https://discuss.pixls.us/t/blender-agx-in-darktable-proof-of-concept/48697/
    The tinting sliders are not implemented, no one seemed to require them at pixls, and I think darktable provides plenty of controls to implement that in other modules.
  • Based on @EaryChow's advice, the hue restoration has been set to a default of 0, rather than 60% (which would correspond to the 40% used in his script, because of inverse mixing logic), as he has received a lot of criticism over that.
  • iop_profile.c has been altered to make the output profile available as a source of base primaries. It is not essential to the module, but I think it would be useful to keep, e.g. for future gamut compression code. If accepted, maybe it'd make sense to update sigmoid, as well, where sRGB can currently be selected as a set of base primaries, too.
  • Warning: much of the more complex UI code (especially that related to the plot of the sigmoid curve) was generated using LLMs, as I don't know GTK or any other GUI.
  • I have squashed my changes, I don't think my close to 150 commits of trials and attempts would provide much benefit to anyone.

(TBH, I'm scared witless. I feel like I'm in The Emperor's New Clothes, and I'm no emperor, just a clown, to be exposed to the world -- and being aware of the situation just makes it worse.)

@TurboGit TurboGit added this to the 5.4 milestone Jun 29, 2025
@TurboGit TurboGit added priority: medium core features are degraded in a way that is still mostly usable, software stutters feature: new new features to add scope: image processing correcting pixels documentation-pending a documentation work is required release notes: pending labels Jun 29, 2025
@TurboGit TurboGit self-requested a review June 29, 2025 16:41
Copy link
Member

@TurboGit TurboGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet tested, only a first pass on the code, just some QA checks.

@@ -25,3 +25,5 @@ output*png
Brewfile.lock.json
CMakeLists.txt.user
workspace/
cmake-build-debug/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes in this file are probably superfluous.

@@ -0,0 +1,2286 @@
#include "bauhaus/bauhaus.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need the standard file header.

#include <pango/pangocairo.h>
#include <stdlib.h>

DT_MODULE_INTROSPECTION(2, dt_iop_agx_user_params_t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we want to keep the legacy here. I would start at 1 for the first integration. People having used the dev versions know that there won't be compatibility.

const char **description(dt_iop_module_t *self)
{
return dt_iop_set_description(self,
_("Applies a tone mapping curve.\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No capital letters on default strings.

return hash;
}

static gboolean _agx_primaries_equal(gconstpointer a, gconstpointer b)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add inline here?

GtkWidget *parent = self->widget;

GtkWidget *settings_page
= dt_ui_notebook_page(gui_data->notebook, N_("settings"), _("main look and curve settings"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= should be above

gui_update(self);
}

static float _degrees_to_radians(float degrees)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline + const

Maybe adding this in common/math.c (deg2rad) ?

dt_dev_add_history_item(darktable.develop, self, TRUE);
}

void commit_params(dt_iop_module_t *self, dt_iop_params_t *gui_params, dt_dev_pixelpipe_t *pipe,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one parameter per line

{
const dt_iop_agx_gui_data_t *gui_data = self->gui_data;

if (picker == gui_data->black_exposure_picker) apply_auto_black_exposure(self);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style:

  if (picker == gui_data->black_exposure_picker) 
     apply_auto_black_exposure(self);
  else if (picker == gui_data->white_exposure_picker) 
     apply_auto_white_exposure(self);
  else if (picker == gui_data->range_exposure_picker) 
     apply_auto_tune_exposure(self);
  else if (picker == gui_data->basic_curve_controls_settings_page.curve_pivot_x_shift 
           || gui_data->curve_tab_enabled && picker == gui_data->basic_curve_controls_curve_page.curve_pivot_x_shift)
   {
...

dt_gui_presets_add_generic(_("smooth|punchy"), self->op, self->version(), &user_params, sizeof(user_params), 1, DEVELOP_BLEND_CS_RGB_SCENE);
}

void gui_cleanup(dt_iop_module_t *self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation-pending a documentation work is required feature: new new features to add priority: medium core features are degraded in a way that is still mostly usable, software stutters release notes: pending scope: image processing correcting pixels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants